package com.yc.web.servlets;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;
import java.lang.reflect.InvocationTargetException;
import java.text.ParseException;
import java.util.Arrays;

@WebServlet("/count.action")
public class CountServlet extends BaseServlet{
    public void getCount(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException, InvocationTargetException, InstantiationException, IllegalAccessException, ParseException {
        int[] data = {32, 50, 60, 720, 880};
        // 设置响应内容类型
        resp.setContentType("application/json");

        // 实际应用中，这里应该是从数据库中获取真实的数据
        // 这里直接模拟返回模拟的数据库数值数组
        String jsonResponse = Arrays.toString(data);

        // 将数据写入响应
        PrintWriter out = resp.getWriter();
        out.println(jsonResponse);
//        super.writeObiectJson(data,resp);
    }
}
